import type { MutableRefObject } from 'react';
import { extendApi } from '@inbiz/utils';

export default extendApi(
  (
    _events: MutableRefObject<Record<string, () => any>>,
    mySummary,
    $hiddenButtons,
    processvars,
    $selected,
  ) => {
    return {
      setVar: (val: any) => {
        processvars.current = Object.assign({}, processvars.current, val);
        return processvars.current;
      },
      getVarList: () => {
        return processvars.current;
      },
      removeVar: (key) => {
        delete processvars.current[key];
        return processvars;
      },
      setRemark: (val) => {
        mySummary.current = val;
      },
      setHiddenButtons: (val) => $hiddenButtons(val),
      setCcMember: (members: any[]) => {
        $selected(members);
      }
    };
  },
);
